package com.newtouch.bxzs.database.synchronize.quartz;

import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 任务调度中心
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2020/12/25 10:25</td>
 * <td>Amour</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author yuanjie
 * @version 1.0.0
 * @since 1.0.0
 */

@Component
public class QuartzJobScheduler {

    @Autowired
    private Scheduler scheduler;

    @Autowired
    private QuartzTrigger quartzTrigger;
    @Autowired
    private QuartzJobDetail quartzJobDetail;

    @PostConstruct
    public void startJob() throws SchedulerException {
        scheduler.scheduleJob(quartzJobDetail.synchronizeCustomerJob(),quartzTrigger.synchronizeCustomerTrigger());
        scheduler.scheduleJob(quartzJobDetail.synchronizeIncomeJob(),quartzTrigger.synchronizeIncomeTrigger());
        scheduler.scheduleJob(quartzJobDetail.synchronizeUserJob(),quartzTrigger.synchronizeUserTrigger());
        scheduler.scheduleJob(quartzJobDetail.synchronizeOrganJob(),quartzTrigger.synchronizeOrganTrigger());
        scheduler.scheduleJob(quartzJobDetail.synchronizeAchievementJob(),quartzTrigger.synchronizeAchievementTrigger());
        scheduler.scheduleJob(quartzJobDetail.synchronizeProductJob(),quartzTrigger.synchronizeProductTrigger());
        scheduler.scheduleJob(quartzJobDetail.updateStatusJob(),quartzTrigger.updateStatusTrigger());
        scheduler.scheduleJob(quartzJobDetail.remainToUpgradeJob(),quartzTrigger.remainToUpgradeTrigger());
    }
}
